package com.imagination.applet.controller.api;

import com.imagination.applet.controller.api.request.ApplyFaceSwapRequest;
import com.imagination.applet.controller.api.response.ApplyFaceSwapResponse;
import com.imagination.applet.controller.web.configuration.UserHolder;
import com.imagination.applet.domain.fsImage.model.FaceSwapImage;
import com.imagination.applet.domain.fsImage.service.FaceSwapImageCommandService;
import com.imagination.applet.infrastructure.common.RestResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * ai模板
 */
@RequestMapping("/face-swap")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class FaceChangingController {

    private final FaceSwapImageCommandService faceChangingImageCommandService;

    /**
     * apply face swap
     */
    @PostMapping(value = "/apply")
    public RestResponse<?> apply(@RequestBody ApplyFaceSwapRequest request) {
        FaceSwapImage image = faceChangingImageCommandService.applyFaceChanging(UserHolder.getUserId(), request.getPhotoId(), request.getAiImageId());
        return RestResponse.ok(ApplyFaceSwapResponse.of(image));
    }

}
